<template>
    <div>
        年龄:
        <input type="text" v-model="age">
        <button @click="onOk">ok</button>
    </div>
</template>

<script>
import eventBus from "../EventBus";
export default {
	data() {
		return {
            age: eventBus.person.age,
        };
	},
    methods: {
        onOk () {
            eventBus.$emit('changeAge', this.age);
            eventBus.$emit('changeName', 'niha');
            //使用场景：一个组件获取另一个组件的DOM
            //this.$nextTick的回调函数是在全部组件DOM更新完成后触发的
            this.$nextTick(() => {
                console.log(document.querySelector('#name').innerHTML);
            })
        }
    }
};
</script>

<style scoped>
</style>